using System.ComponentModel.DataAnnotations;

namespace DaoHang.Models
{
    /// <summary>
    /// 日志条目数据模型
    /// </summary>
    public class LogEntry
    {
        /// <summary>
        /// 日志ID
        /// </summary>
        [Key]
        public int Id { get; set; }

        /// <summary>
        /// 日志级别
        /// </summary>
        [Required]
        [MaxLength(20)]
        public string Level { get; set; } = string.Empty;

        /// <summary>
        /// 日志分类
        /// </summary>
        [MaxLength(100)]
        public string Category { get; set; } = string.Empty;

        /// <summary>
        /// 日志消息
        /// </summary>
        [Required]
        public string Message { get; set; } = string.Empty;

        /// <summary>
        /// 异常信息
        /// </summary>
        public string? Exception { get; set; }

        /// <summary>
        /// 日志记录器名称
        /// </summary>
        [MaxLength(255)]
        public string? Logger { get; set; }

        /// <summary>
        /// 日志时间戳
        /// </summary>
        public DateTime Timestamp { get; set; } = DateTime.Now;

        /// <summary>
        /// 用户IP地址
        /// </summary>
        [MaxLength(45)]
        public string? IpAddress { get; set; }

        /// <summary>
        /// 用户代理
        /// </summary>
        [MaxLength(500)]
        public string? UserAgent { get; set; }

        /// <summary>
        /// 请求URL
        /// </summary>
        [MaxLength(500)]
        public string? RequestUrl { get; set; }

        /// <summary>
        /// 用户名
        /// </summary>
        [MaxLength(100)]
        public string? Username { get; set; }

        /// <summary>
        /// 附加属性（JSON格式）
        /// </summary>
        public string? Properties { get; set; }
    }
} 